<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:57:"D:\www\fdc\public/../application/home\view\map\index.html";i:1494035360;s:58:"D:\www\fdc\public/../application/home\view\map\layout.html";i:1493598458;}*/ ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<!-- manifest="cache.manifest" -->
<head>
    <meta charset="utf-8" />
    <title><?php echo $seo['title']; ?></title>
    <meta name="keywords" content="<?php echo $seo['keys']; ?>" />
    <meta name="description" content="<?php echo $seo['desc']; ?>" />
    <link type="text/css" rel="stylesheet"  href="__CSS__/format_dom.css"/>
    <link type="text/css" rel="stylesheet"  href="__CSS__/main.css"/>
    <!--[if lte IE 8]>
    <script src="__JS__/ie/html5shiv.js"></script>
    <![endif]-->
    <!--[if IE 6]>
    <script type="text/javascript" src="__JS__/DD_belatedPNG.js"></script>
    <script type="text/javascript">DD_belatedPNG.fix("*")</script>
    <![endif]-->
    <script src="__PUBLIC__/js/jquery.min.js"></script>
    <style>
        /*地图搜索*/
        .map{ margin: 0 auto; min-width: 1200px; position: relative;}
        .map_left{overflow: hidden; float: left; padding-right: 380px; min-width: 1000px;background: #cccccc}
        .map_left .map-region{width: 100px; height: 100px; display: block; border-radius: 50%; background:rgba(0,190,120,0.9); overflow: hidden;}
        .map_left .map-region:hover{background:#FF611B; text-decoration: none;}
        .map-region .region{text-align: center; font-size: 16px; color: #fff; margin-top: 25px; margin-bottom: 5px;}
        .map-region .all{text-align: center; font-size: 14px; color: #fff; }
        .map_right{overflow: hidden; float: right; width: 380px; background: #fff; border-left: 1px solid #ddd; position: absolute; top:0px; right:0;}
        .map_right .map_right_1{margin:0 auto; width: 380px; border-top: 1px solid #ddd;}
        .map_right .map_right_1 ul{margin:0 auto; padding:20px 15px;}
        .map_right .map_right_1 ul li{float: left; margin-right: 10px; margin-bottom: 10px; position: relative;}
        .map_right .map_right_1 ul li:nth-child(3n){margin-right: 0;}
        .map_right .map_right_1 ul li span{width: 78px; font-size: 14px; color: #333;border: 1px solid #ddd; padding:5px 15px; display: block; overflow: hidden; position: relative;}
        .map_right .map_right_1 ul li span:after{content: ""; width: 0px; height: 0px; display: block; border: 5px solid transparent; border-top-color: #333; border-bottom: none; position: absolute; top:50%; right:15px; margin-top: -2px;}
        .map_right .map_right_1 ul li div{width: 78px; padding: 0 15px; border: 1px solid #ddd; border-top: none; position: absolute; top:31px; left:0; background: #fff; z-index: 99;  display: none;}
        .map_right .map_right_1 ul li div a{font-size: 14px; color: #333; text-align: left; display: block; line-height: 30px;height:30px;overflow:hidden;}
        .map_right .map_right_1 ul li div a:hover{color: #FF611B; text-decoration: none;}
        .map_right .map_right_2{overflow: hidden; margin:0 auto; width: 380px;}
        .map_right .map_right_2 h3{overflow: hidden; margin:0 auto; background: #F2F2F2; line-height: 40px; font-size: 14px; font-weight: normal; padding: 0 15px;}
        .map_right .map_right_2 h3 span{color: #999;}
        .map_right .map_right_2 h3 span em{color:#FF611B !important; margin: 0 5px;}
        .map_right .map_right_2 ul{overflow: hidden; overflow-y: auto;}
        .map_right .map_right_2 ul li{overflow: hidden; margin: 0 auto;padding:15px;}
        .map_right .map_right_2 ul li a{overflow: hidden;}
        .map_right .map_right_2 ul li p{margin-bottom: 5px;}
        .map_right .map_right_2 ul li p:nth-of-type(1){line-height: 17px; font-size: 16px; margin-bottom: 5px;}
        .map_right .map_right_2 ul li p:nth-of-type(1) span{font-size: 12px; color: #fff; background: #f25824;text-align: center;line-height: 16px; padding: 1px 3px; margin: 0 5px;}
        .map_right .map_right_2 ul li:hover{background: #f8f8f8;}
        .map_right .map_right_2 ul li:hover a{text-decoration: none;}
        .map_right .map_right_2 ul li:hover .area{color: #333;}
        .map_right .map_right_2 .area{color: #666;}
        .map_right .map_right_2 .aver{color: #FF611B;}
        .map_right .map_right_2 .line{background: #bbb; margin: 0 8px; vertical-align: middle;text-indent: -999em; width: 1px; height: 12px; display: inline-block;}
        .map_right .map_right_2 ul li:hover .aver{color: #FF611B;}
        .map_right .map_hsimg{overflow: hidden; float: left; width: 100px; margin-right: 15px;}
        .map_right .map_hsimg img{width: 100px; height: 75px; display: block; margin:0 auto;}
        .map_right .map_info{overflow: hidden; float: left; width: 218px;}
        .map_right .map_info div{overflow: hidden; margin: 0 auto;}
        .map_right .map_info div span{font-size: 14px;padding: 1px 5px; float: left;margin-right: 5px;}
        .map_right .map_info div span:nth-child(3n){margin-right: 0;}
        .map_right .map_info div span:nth-of-type(1){color: #08af3b; border: 1px solid #08af3b;}
        .map_right .map_info div span:nth-of-type(2){color: #ff9934; border: 1px solid #ff9934;}
        .map_right .map_info div span:nth-of-type(3){color: #4a90e2; border: 1px solid #4a90e2;}
        .top_line{height:50px;line-height: 50px;font-size:15px;}
    </style>
</head>
<body>
<div>
    <div class="top_line">
        <div class="main">
            <ul>
                <li><img src="<?php echo $site['mobileLogo']; ?>" alt="<?php echo $site['title']; ?>" style="display: block;"></li>
                <?php if(is_array($menu) || $menu instanceof \think\Collection || $menu instanceof \think\Paginator): $i = 0; $__LIST__ = $menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;if($vo['pos'] == 1): if(!(empty($vo['url']) || (($vo['url'] instanceof \think\Collection || $vo['url'] instanceof \think\Paginator ) && $vo['url']->isEmpty()))): $url = $vo['url']; else: if(!(empty($vo['alias']) || (($vo['alias'] instanceof \think\Collection || $vo['alias'] instanceof \think\Paginator ) && $vo['alias']->isEmpty()))): $url=url($vo['model'].'/detail',['cate'=>$vo['alias']]); else: $url=url($vo['model'].'/index'); endif; endif; ?>
                <li><a href="<?php echo $url; ?>" title="<?php echo $vo['title']; ?>" target="<?php echo $vo['open_type']; ?>" <?php if($vo['model'] == $controller): ?>class="on"<?php endif; ?>><?php echo $vo['title']; ?></a></li>
                <?php endif; endforeach; endif; else: echo "" ;endif; ?>
                <li><a href="<?php echo url('Agency/index'); ?>">经纪人</a></li>
            </ul>
            <?php if(empty($userInfo) || (($userInfo instanceof \think\Collection || $userInfo instanceof \think\Paginator ) && $userInfo->isEmpty())): ?>
            <span><a href="<?php echo url('user.login/index'); ?>" >登录</a></span>
            <span><a href="<?php echo url('user.login/reg'); ?>" >注册</a></span>
            <?php else: ?>
            <div style="float:right;color:#fff;"><em><?php echo $userInfo['nickname']; ?></em>,欢迎您的到来 <a href="<?php echo url('user.index/index'); ?>">会员中心</a> | <a href="<?php echo url('user.login/logout'); ?>">退出</a></div>
            <?php endif; ?>
        </div>
    </div>

</div>

<div class="map" id="mapWrap">
    <div class="map_left" id="mapLeft" style="height: auto;">

    </div>
    <div class="map_right" id="mapRight">
        <div class="map_right_1">
            <ul id="attr">
                <li>
                    <span data-bid="0" data-acttype="area_id" id="area_id">区域</span>
                    <div>
                        <a data-bid="0" data-type="区域" href="javascript:;">不限</a>
                        <?php if(is_array($area) || $area instanceof \think\Collection || $area instanceof \think\Paginator): $i = 0; $__LIST__ = $area;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                            <a data-bid="<?php echo $vo['id']; ?>" href="javascript:;"><?php echo $vo['name']; ?></a>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </div>
                </li>
                <li>
                    <span data-bid="0" id="room">户型</span>
                    <div>
                        <a data-bid="0" href="javascript:;">不限</a>
                        <?php if(is_array($room) || $room instanceof \think\Collection || $room instanceof \think\Paginator): $i = 0; $__LIST__ = $room;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                            <a data-bid="<?php echo $vo['id']; ?>" href="javascript:;"><?php echo $vo['name']; ?></a>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </div>
                </li>
                <li>
                    <span data-bid="0" id="price">价格</span>
                    <div>
                        <a data-bid="0" href="javascript:;">不限</a>
                        <?php if(is_array($price) || $price instanceof \think\Collection || $price instanceof \think\Paginator): $i = 0; $__LIST__ = $price;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                            <a data-bid="<?php echo $key; ?>" href="javascript:;"><?php echo $vo['name']; ?></a>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </div>
                </li>
                <li>
                    <span data-bid="0" id="tags">特色</span>
                    <div>
                        <a data-bid="0" href="javascript:;">不限</a>
                        <?php if(is_array($tags) || $tags instanceof \think\Collection || $tags instanceof \think\Paginator): $i = 0; $__LIST__ = $tags;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                            <a data-bid="<?php echo $vo['id']; ?>" href="javascript:;"><?php echo $vo['name']; ?></a>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </div>
                </li>
                <li>
                    <span data-bid="0" id="renovation">装修</span>
                    <div>
                        <a data-bid="0" href="javascript:;">不限</a>
                        <?php if(is_array($renovation) || $renovation instanceof \think\Collection || $renovation instanceof \think\Paginator): $i = 0; $__LIST__ = $renovation;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                            <a data-bid="<?php echo $vo['id']; ?>" href="javascript:;"><?php echo $vo['name']; ?></a>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </div>
                </li>
                <li>
                    <span data-bid="0" id="house_type">类型</span>
                    <div>
                        <a data-bid="0" href="javascript:;">不限</a>
                        <?php if(is_array($house_type) || $house_type instanceof \think\Collection || $house_type instanceof \think\Paginator): $i = 0; $__LIST__ = $house_type;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                        <a data-bid="<?php echo $vo['id']; ?>" href="javascript:;"><?php echo $vo['name']; ?></a>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </div>
                </li>
            </ul>
        </div>
        <div class="map_right_2">
            <h3><span>共有<em id="count">0</em>个楼盘</span></h3>
            <ul id="lists" data-uri="<?php echo url('Map/getHouseList'); ?>"></ul>
        </div>
    </div>
</div>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=<?php echo $ak; ?>"></script>
<script type="text/html" id="template">
    {{# for(var i = 0, len = d.length; i < len; i++){ }}
    <li onclick="fang_cms_map('{{d[i].lng}}','{{d[i].lat}}','{{d[i].id}}','{{d[i].title}}','{{d[i].img}}','{{d[i].address}}','{{d[i].sale_phone.phone}}{{# if(d[i].sale_phone.fenhao){ }}转{{d[i].sale_phone.fenhao}}{{# }}}','{{d[i].youhui}}','{{d[i].average_price}}','{{d[i].house_status}}')">
        <a href="javascript:void(0)">
            <div class="map_hsimg">
                <img src="{{d[i].img}}" width="100" height="75" alt="{{d[i].title}}">
            </div>
            <div class="map_info">
                <p>{{d[i].title}}</p>
                <p>
                    <span class="area">{{d[i].city_name}}-{{d[i].area_name}}</span>
                    <span class="aver">{{d[i].average_price}}元/平米</span>
                </p>
                <div>
                    {{# for(var j = 0,length = d[i]['tags_name'].length; j < length ; j++){ }}
                    <span>{{d[i]['tags_name'][j]}}</span>
                    {{# } }}
                </div>
            </div>
        </a>
    </li>
    {{# } }}
</script>
<script src="__PUBLIC__/js/layer/laytpl.js"></script>
<script>
    //javascript的数组扩展方法
    Array.prototype.contains = function (obj) {
        var i = this.length;
        while (i--) {
            if (this[i] === obj) {
                return true;
            }
        }
        return false;
    }
    $(document).ready(function () {
        $("#mapWrap").height($(window).height());
        $(window).resize(function () {
            $("#mapWrap").height($(window).height());
        });
        $('#mapLeft,#mapRight').css('height', $(window).height() - 60);
        $(window).resize(function () {
            $('#mapLeft,#mapRight').css('height', $(window).height() - 60);
        });
        $('.map').css('height', $(window).height() - 50);
        $(window).resize(function () {
            $('.map').css('height', $(window).height() - 50);
        });
    });
</script>
<script type="text/javascript">
    var height = document.documentElement.clientHeight;
    var width = document.documentElement.clientWidth;
    var lvjupath ="http://" + window.location.host;
    var houseID = ""; //缓存已经加载过的楼盘ID，以字符串形式，ID间用逗号相隔
    // 百度地图API功能
    var mp = new BMap.Map("mapLeft", { enableMapClick: false });
    mp.centerAndZoom(new BMap.Point(110.31327, 20.030473), 15);
    mp.addControl(new BMap.NavigationControl());               // 添加平移缩放控件
    mp.addControl(new BMap.ScaleControl());                    // 添加比例尺控件

    mp.addControl(new BMap.OverviewMapControl());              // 添加缩略地图控件
    mp.enableScrollWheelZoom(); 							   // 启用滚轮放大缩小
    var positions = new Array("0", "-20", "-10", "-30");
    var backgroundColors = new Array("#33C0D0", "#fc5172", "#ff9600", "#9e9e9e");
    var borders = new Array("#0D5780", "#CC0066", "#FF6600", "#4B4B4B");
    ///////////////////////////
    //var optionsList = new Array("周边楼盘", "公交", "餐饮", "银行", "学校", "医院", "购物,超市");
    //var select_index = 0;
    //var findbuildarr = '';
    //var searchlocal = '';
    ///////////////////////////
    // 复杂的自定义覆盖物

    //point_lng：x坐标
    //point_lat：y坐标
    //text：标题

    //mouseoverText：鼠标移动上去后的显示

    //type：backgroundColors数组的颜色，直接用 数字 ，表示它的下标

    //bid：楼盘的ID，用于连接的跳转
    //address：楼盘的地址
    //path：楼盘图片地址

    //phone1 与 phone2：会显示为phone1转phone2，例如：400转100
    //discount：优惠信息

    //newslink:楼盘最新新闻链接地址
    function ComplexCustomOverlay(point_lng, point_lat, text, mouseoverText, type, bid, address, path, phone1, discount) {
        this._point = new BMap.Point(point_lng, point_lat);
        this._text = text;
        this._overText = mouseoverText;
        this._type = getType(type);
        this._y_type = type;
        this._bid = bid;
        this._point_lng = point_lng;
        this._point_lat = point_lat;
        this._address = address;
        this._path = path;
        this._phone1 = phone1;
        this._discount = discount;
    }
    ComplexCustomOverlay.prototype = new BMap.Overlay();
    ComplexCustomOverlay.prototype.initialize = function (map) {
        this._map = map;
        var div = this._div = document.createElement("div");
        div.style.position = "absolute";
        div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
        div.style.backgroundColor = backgroundColors[this._type];
        div.style.border = "1px solid " + borders[this._type];
        div.style.color = "white";
        div.style.height = "18px";
        div.style.padding = "2px";
        div.style.cursor = "pointer";
        div.style.lineHeight = "18px";
        div.style.whiteSpace = "nowrap";
        div.style.MozUserSelect = "none";
        div.style.fontSize = "12px"
        var span = this._span = document.createElement("span");
        div.appendChild(span);
        //调整地图楼盘初始显示价格
        span.appendChild(document.createTextNode(this._overText));
        var that = this;
        var arrow = this._arrow = document.createElement("div");
        arrow.style.background = "url(__IMG__/label.png) no-repeat";
        arrow.style.backgroundPosition = "0px " + positions[this._type] + "px";
        arrow.style.position = "absolute";
        arrow.style.width = "11px";
        arrow.style.height = "10px";
        arrow.style.top = "22px";
        arrow.style.left = "10px";
        arrow.style.overflow = "hidden";
        div.appendChild(arrow);
        div.onmouseover = function () {
            map_mouseover(div, arrow, that);
        }
        div.onmouseout = function () {
            map_mouseout(div, arrow, that);
        }
        //20和21 用于网上售楼处地图交通里面的显示, 不需要onclick事件
        if (this._y_type != 21 && this._y_type != 20 && this._y_type != 19) {
            div.onclick = function () {
                select_point = new BMap.Point(that._point_lng, that._point_lat);
                select_bid = that._bid;
                select_bname = that._text;
                select_path = that._path;
                select_address = that._address;
                select_type = that._y_type;
                select_overText = that._overText;
                select_phone1 = that._phone1;
                select_discount = that._discount;
                select_price = select_overText.replace(select_bname, "");
                select_price = select_price.replace('元/㎡','');
                fang_cms_oncilck();
            }
        }
        mp.getPanes().labelPane.appendChild(div);
        return div;
    }
    ComplexCustomOverlay.prototype.draw = function () {
        var map = this._map;
        var pixel = map.pointToOverlayPixel(this._point);
        this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
        this._div.style.top = pixel.y - 30 + "px";
    }
    function getType(type) {
        if (type == 42 || type == 43) {
            return 0;
        }else if(type == 41){
            return 2;
        } else if (type == 44 || type==40) {
            return 3;
        } else {
            return 1;
        }
    }
    function map_mouseover(div, arrow, that) {
        div.style.backgroundColor = backgroundColors[2];
        $(div).css("z-index", "9999");
        div.style.borderColor = borders[2];
        div.getElementsByTagName("span")[0].innerHTML = that._overText;
        arrow.style.backgroundPosition = "0px " + positions[2] + "px";
    }
    function map_mouseout(div, arrow, that) {
        div.style.backgroundColor = backgroundColors[that._type];
        $(div).css("z-index", "1");
        div.style.borderColor = borders[that._type];
        //鼠标移出后楼盘显示内容不变

        div.getElementsByTagName("span")[0].innerHTML = that._overText;
        arrow.style.backgroundPosition = "0px " + positions[that._type] + "px";
    }

    function get_url($k){
        if($k=='detail'){
            var url = "<?php echo url('Loupan/detail',array('id'=>'@id@')); ?>";
        }
        if($k=='pic'){
            var url = "<?php echo url('Loupan/pic',array('house_id'=>'@id@')); ?>";
        }
        if($k=='info'){
            var url = "<?php echo url('Loupan/info',array('house_id'=>'@id@')); ?>";
        }
        if($k=='type'){
            var url = "<?php echo url('Loupan/type',array('house_id'=>'@id@')); ?>";
        }
        if($k=='ask'){
            var url = "<?php echo url('Loupan/question',array('house_id'=>'@id@')); ?>";
        }
        if($k=='news'){
            var url = "<?php echo url('Loupan/news',array('house_id'=>'@id@')); ?>";
        }
        url = decodeURIComponent(url);
        url = url.replace('@id@',select_bid);
        return url;
    }

    function fang_cms_oncilck() {
        msgwindow = 1;
        var phone = "<span style='color:#FF6400'><strong>" + select_phone1 + "</strong></span>";
        var sContent = "<div style='width:400px;'>";
        sContent += "<div style='float:left;width:100px; padding:30px 10px 0px 0px;overflow:hidden;'><img src=\"" + select_path + "\" style='width:100px;height:71px;'></div>";
        sContent += "<div style='width:290px;overflow:hidden;'>";
        sContent += "<h4>";
        sContent += "<a href='"+get_url('detail')+"' target='_blank' style='color:#006699;'>" + select_bname + "</a></h4>";
        sContent += "<p style='margin:0;line-height:22px;color:#999;'>参考均价：<span style='color:#FF6400;'><strong>" + (select_price == '' ? '  预登记' : select_price + "元/㎡") + "</strong></span></p>";
        if (select_phone1 != "") sContent += "<p style='margin:0;line-height:22px;color:#999;'>咨询电话：<span id='phone' style='color:#333;'>" + phone + "</span></p>";
        if (select_discount != "") sContent += "<p style='margin:0;line-height:22px;color:#999;'>优惠信息："+select_discount+"</p>";
        sContent += "<p style='margin:0;line-height:22px;color:#999;'>楼盘地址：<span id='address_" + select_bid + "' style='color:#333;'>" + select_address + "</span></p>";
        sContent += "<p style='color:#006699;'></p>";
        if(select_type = '22'){
            sContent += "<p style='margin:0;line-height:22px;color:#999;'>" +
                    "<span ><a style='color:#006699;' href='"+get_url('detail')+"' target='_blank'>主页</a>&nbsp;&nbsp;" +
                    "<span ><a style='color:#006699;' href='"+get_url('info')+"' target='_blank'>详细</a>&nbsp;&nbsp;" +
                    "<span ><a style='color:#006699;' href='"+get_url('type')+"' target='_blank'>户型</a>&nbsp;&nbsp;" +
                    "<span ><a style='color:#006699;' href='"+get_url('pic')+"' target='_blank'>图片</a>&nbsp;&nbsp;" +
                    "<span ><a style='color:#006699;' href='"+get_url('news')+"' target='_blank'>动态</a>&nbsp;&nbsp;" +
                    "<span ><a style='color:#006699;' href='"+get_url('ask')+"' target='_blank'>问答</a>&nbsp;&nbsp;" +
                    "</span></p>";
        }
        sContent += "</div>";
        sContent += "</div>";
        // 为调用后台sendMsg方法添加的bid属性
        sContent += "<input type='hidden' name='bid' id='bid' value='" + select_bid + "'/>";
        var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象
        mp.openInfoWindow(infoWindow, select_point);      // 打开信息窗口
    }
    //点击选中楼盘，地图自动移到楼盘处（待修改）

    function fang_cms_map(lnt, lat, bid, bname, path, address, phone1, discount, price,type) {
        select_point = new BMap.Point(lnt, lat);
        select_bid = bid;
        select_bname = bname;
        select_path = path;
        select_address = address;
        select_phone1 = phone1;
        select_discount = discount;
        select_price = price;
        select_type = type;
        mp.panTo(select_point);
        fang_cms_oncilck();
    }

</script>
<script>
    $(function(){
        $("#attr li").hover(function(){
            $(this).find('div').show();
        },function(){
            $(this).find('div').hide();
        });
        $("#attr li a").bind('click',function(){
            var id = $(this).data('bid');
            var span = $(this).parents('li').find('span');
            span.attr('data-bid',id);
            span.text($(this).text());
            $(this).parent().hide();
            getData();
        });
        $("#sort a").click(function(){
            var s = $(this).attr('data-did');s=parseInt(s);
            var param = getVal();
            if(s==3){
                $(this).attr('data-did',4);
            }
            if(s==4){
                $(this).attr('data-did',3);
            }
            param.sort = s;
            getData(param);
        });
        $('#so_btn').bind('click',function(){
            var keyword = $("#key").val();
            if(!keyword){
                alert('请输入关键词搜索');
                return false;
            }
            getData({keyword:keyword});
        });
        getData();
    });
    function getVal(){
        var area = $('#area_id').attr('data-bid'),
                room = $('#room').attr('data-bid'),
                tags = $('#tags').attr('data-bid'),
                price = $('#price').attr('data-bid'),
                house_type = $('#house_type').attr('data-bid'),
                renovation = $('#renovation').attr('data-bid');
        var param = {
            area : area,
            room : room,
            tags :tags,
            price : price,
            house_type : house_type,
            renovation : renovation
        };
        return param;
    }
    function getData(param){
        if(!param){
            param = getVal()
        }
        var url = $('#lists').data('uri');
        $.get(url,param,function(result){
            if(result.status == 1){
                var gettpl = document.getElementById('template').innerHTML;
                laytpl(gettpl).render(result.data, function(html){
                    document.getElementById('lists').innerHTML = html;
                });
                var arrHouseID = houseID.substring(0, houseID.length - 1).split(','); //将已经加载的楼盘的ID字符串转成数组

                $(result.data).each(function (i, ite) {
                    if (!arrHouseID.contains(ite.id.toString())) {
                        var discount = ite.group_youhui ? ite.group_youhui : ite.youhui;
                        var tel = ite.sale_phone.phone;
                        if(ite.sale_phone.fenhao){
                            tel+='转'+ite.sale_phone.fenhao;
                        }
                        var txt = ite.title, mouseoverTxt = txt + " " + ite.average_price+'元/㎡';
                        var myCompOverlay = new ComplexCustomOverlay(ite.lng, ite.lat, ite.title, mouseoverTxt, ite.house_status, ite.id, ite.address, ite.img, tel, discount);
                        mp.addOverlay(myCompOverlay);
                        houseID += ite.id.toString() + ","; //保存已经加载的楼盘ID

                    }
                });
                if (result.data.length > 0) {
                    var discount = result.data[0].group_youhui ? result.data[0].group_youhui : result.data[0].youhui;
                    var tel = result.data[0].sale_phone.phone;
                    if(result.data[0].sale_phone.fenhao){
                        tel+='转'+result.data[0].sale_phone.fenhao;
                    }
                    fang_cms_map(result.data[0].lng, result.data[0].lat, result.data[0].id, result.data[0].title, result.data[0].img, result.data[0].address, tel, discount, result.data[0].average_price,result.data[0].house_status);
                }
                $(".mapList").scrollTop(0);
            }else{
                document.getElementById('lists').innerHTML = '<li>暂无相关数据</li>';
            }
            $('#count').text(result.total);
        });
    }
</script>


</body>
</html>
